#ifndef H_COMS
#define H_COMS

/* Modem commands */
#define MOD_SLEEP 0x80
#define MOD_WAKE  0xFF
#define MOD_ENQ0  0x40
#define MOD_TXSTT 0xBF /* May need to be changed for different timing */
#define MOD_TXEND 0x20

/* Modem received characters */
#define MOD_RQD   0x01
#define MOD_WAKAK 0x02
#define MOD_ACK   0x00

/* Modem enquire errors */
#define MOD_CHANBUSY    0x01 /* Channel busy */
#define MOD_DATACARRIER 0x02 /* Data carrier detected */
#define MOD_TRANSMITON  0x04 /* Transmitter on */
#define MOD_TESTMODEON  0x08 /* Test mode on */
#define MOD_SYNCOUTLOCK 0x10 /* Synchroniser out of lock (error) */
#define MOD_RXBUFOVER   0x20 /* RX buffer overflow (error) */
#define MOD_TXBUFOVER   0x40 /* TX buffer overflow (error) */
#define MOD_POWERONRST  0x80 /* Power on reset status (error) */

#define MOD_TIMEOUT 100000 /* About 12ms or longer */
#define MOD_SETUPRETRY 100 /* Number of times to retry modem init */
#define MOD_MAXBUGS 100 /* Number of times commands have to be retried before initialising modem again */

/* External functions */
void comsInit(void);
int comsSend(unsigned char mod_in, int sendtype, int replytype, unsigned char replychar);
int modInit();
int modENQ0();
int modTransmit(unsigned char *data, int arraysize);

/* Interrupts */
interrupt(USART1RX_VECTOR) receivetrigger();
interrupt(USART1TX_VECTOR) transmittrigger();

#endif /* H_COMS */
